<template>
	<view class="wrap">
		<js-error mode="bottom" ref="jsError"></js-error>
		<view class="action bg-white "
			style="padding: 15px 0 0 10px;font-size: 20px;align-items: center;display: flex;">
			<u-icon name="/static/image/detail.png" size="80"></u-icon>
			<text class="cuIcon-titles text-bold">废旧物资明细</text>
		</view>

		<u-form class="form bg-white" :model="model" ref="uForm" label-position="left">
			
			<u-form-item label="合同号:" prop="htNo" label-width="200" required :label-style="{'font-weight':'bold'}">
				<u-input placeholder="请输入" v-model="model.htNo" type="text" di maxlength="64"></u-input>
			</u-form-item>
			<u-form-item label="废旧物资:" prop="invName" label-width="200" required :label-style="{'font-weight':'bold'}">
				<u-input placeholder="请输入" v-model="model.invName" type="text" di maxlength="64"></u-input>
			</u-form-item>
			
			<u-form-item label="客户名称:" prop="cusName" label-width="200" required :label-style="{'font-weight':'bold'}">
				<u-input placeholder="请输入" v-model="model.cusName" type="text" di maxlength="64"></u-input>
			</u-form-item>
			<u-form-item label="规格型号:" prop="invStd" label-width="200"  :label-style="{'font-weight':'bold'}">
				<u-input placeholder="请输入" v-model="model.invStd" type="text" di maxlength="64"></u-input>
			</u-form-item>
			<u-form-item label="单位:" prop="invUnit" label-width="200"  :label-style="{'font-weight':'bold'}">
				<u-input placeholder="请输入" v-model="model.invUnit" type="text" di maxlength="64"></u-input>
			</u-form-item>
			
			<u-form-item label="承运目的地:" prop="cyAddress" label-width="200" :label-style="{'font-weight':'bold'}">
				<u-input placeholder="请输入" v-model="model.cyAddress" type="text" maxlength="64"></u-input>
			</u-form-item>
			
			<u-form-item label="承运单价:" prop="cyPrice" label-width="200" :label-style="{'font-weight':'bold'}">
				<u-input placeholder="请输入" v-model="model.cyPrice" type="digit" di maxlength="64"></u-input>
			</u-form-item>
		
			<u-form-item label="备注:" prop="remarks" label-width="200" :label-style="{'font-weight':'bold'}">
				<u-input placeholder="请输入" v-model="model.remarks" type="text" di maxlength="64"></u-input>
			</u-form-item>
		</u-form>
	
	<view style="height: 70px;"></view>
	
	<view class=" flex cu-bar tabbar bg-white foot cu-modal-footer">
		<button class="cu-btn  bg-confirm lg  " @click="submit">保存</button>
		<button class="cu-btn  lines-red lg margin-left" @click="cancel">返回</button>
	</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				params: {
					year: true,
					month: true,
					day: true,
					hour: true,
					minute: true,
					second: true
				},
				model: {
					isNewRecord:true
				},
				//主表id
				children: [],
				carVenSelectList: [],
				pickerTime: false, //控制日期显示
			}
		},
		onLoad(params) {
			if(params.id){
				this.$u.api.mf.fjformC({id:params.id}).then(res => {
					this.model = res.mfCarplanFjC;
				});
			}else{
				this.model.hid = params.hid
			}
		},
		onShow() {},
		methods: {
			cancel() {
				// uni.$emit('refreshData');
				uni.navigateBack({
					delta: 1,
				})
			},
			
			
			
			
			timeConfirm(e) {
				this.model.planDate = e.year + '-' + e.month + '-' + e.day + ' ' + e.hour + ":" + e.minute + ":" + e
					.second;
			},
			submit(data, callback) {
				
				if(this.model.invName == null || this.model.invName == ''){
					this.$refs.jsError.showError('','请正确填入废旧物资！','error');
					return;
				}else if(this.model.cusName == null || this.model.cusName == ''){
					this.$refs.jsError.showError('','请正确填入客户名称！','error');
					return;
				}else if(this.model.htNo == null || this.model.htNo == ''){
					this.$refs.jsError.showError('','请正确填入合同号！','error');
					return;
				}else{
					var data = this.model;
					this.$u.api.mf.fjsaveDetail(data).then(res => {
						if(res.result == 'true'){
							this.$u.toast(res.message);
							setTimeout(()=>{
								uni.$emit('refreshData');
								uni.navigateBack({
									delta: 1,
								})
							},1000)
							
						}else{
							this.$refs.jsError.showError('',res.message,'error');
						}
					});
				}
			},
		}
	}
</script>
<style lang="less">
	.add {
		position: absolute;
		right: 130rpx;
		top: 0;
		margin-right: 0;
	}

	.cu-bar {
		min-height: 80px;
	}

	.cu-btn {
		font-size: 16px;
		height: 40px;
	}

	.foot {
		background: #fff;
	}

	.cu-item {
		flex-wrap: wrap;
		padding: 8px 15px !important;
	}

	.title {
		width: 100px;
	}


	.button {
		font-size: 32rpx;
		color: #666666;
		line-height: 40rpx;
		padding: 12rpx 40rpx;
		margin-bottom: 20rpx;
		background: #e2e2e2;
		border-radius: 180rpx;
	}

	.button:hover {
		background: #3e97b0;
		color: #ffffff;
	}

	.cu-modal-footer {
		padding: 32rpx 32rpx !important;
		width: 100%;

		.cu-btn {
			width: 50%;
		}
	}

	.bg-confirm {
		background: #3e97b0;
		color: #ffffff;
	}
</style>